import axios from 'axios';

axios.interceptors.request.use( (config:any) => {
    config.headers['Authorization'] = 'bearer '+ localStorage.getItem("token");
    return config;
});
axios.interceptors.response.use(response => {
    return response;
},error => {
    if(error.response.status == 401){
        window.location.href = "/login";
    }
    return Promise.reject(error.response.data);
})

export {axios};
export const url = "/api";